home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / paragen2.zip / VIDLIB.C < prev    next >
C/C++ Source or Header  |  1991-03-28  |  20KB  |  785 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "vlib.h"
  5. #include "vidlib.h"
  6.  
  7. int NumKeys=0;
  8. int FieldNum=0;
  9. BOOLEAN GotSrchKFirst = FALSE;
  10. BOOLEAN GotSrchFFirst = FALSE;
  11.  
  12. static VLIBTABLEENTRY SearchRecord;
  13.  
  14. void main(void);
  15. int OpeningScreen(void);
  16. void DisplayFields(void);
  17.  
  18. void main(void) {
  19.  
  20.     char Choice[4];
  21.  
  22.     if (OpeningScreen()) {
  23.         do    {
  24.             GetString(18,68,2,Choice,YES);
  25.             ClearMessageArea();
  26.         } while (ValidEvent(Choice));
  27.         if ((VLIBRet = PXExit()) != PXSUCCESS)
  28.             VLIBError1(VLIBRet);
  29.     }
  30.     ClearArea(1,1,25,80);
  31. }
  32.  
  33.  
  34. int OpeningScreen(void) {
  35.  
  36.     ClearArea(1,1,25,80);
  37.  
  38.     CenterText(1,1,80,"PARAGen-Video Library Demo..[C Ver 1.4]");
  39.     CenterText(2,1,80,"(C) 90, 91 Innovative Data Solutions, Inc.");
  40.     DrawBox(3,1,13,80,"╡Video Data╞");
  41.     DrawBox(12,4,8,74,"╡Options╞");
  42.     DrawBox(20,1,3,80,"╡Paradox Information╞");
  43.     DrawBox(22,4,4,74,"╡Error and Input Information╞");
  44.     DisplayFields();
  45.     if ((VLIBRet = PXInit()) != PXSUCCESS) {
  46.         VLIBError1(VLIBRet);
  47.         return(0);
  48.     }
  49.     return(1);
  50.  
  51. }
  52.  
  53. void DisplayFields(void) {
  54.  
  55.     PrintText(4,3, "1-Title...:");
  56.     PrintText(4,62,"2-Rating..:");
  57.     PrintText(5,3, "3-Star(s).:");
  58.     PrintText(6,3, "4-Cast....:");
  59.     PrintText(6,48,"5-Director:");
  60.     PrintText(7,3, "6-Company.:");
  61.     PrintText(7,33,"7-Category:");
  62.     PrintText(7,59,"8-Date.:");
  63.     PrintText(9,3, "9-Price:$");
  64.     PrintText(9,23,"10-Tape #:");
  65.     PrintText(9,40,"11-Run Time:");
  66.     PrintText(9,60,"12-Format:");
  67.     PrintText(10,3,"13-Start:");
  68.     PrintText(10,23,"14-Stop.:");
  69.     PrintText(10,40,"15-Rec Speed:");
  70.  
  71.     PrintText(13,5, "AR-Add Record");
  72.     PrintText(14,5, "CT-Close Table");
  73.     PrintText(15,5, "DT-Decrypt Table");
  74.     PrintText(16,5, "DR-Delete Record");
  75.     PrintText(17,5, "ET-Delete Table");
  76.     PrintText(18,5, "ER-Edit Record");
  77.  
  78.     PrintText(13,23,"FR-First Record");
  79.     PrintText(14,23,"GR-Goto Record");
  80.     PrintText(15,23,"KF-Srch Key 1st");
  81.     PrintText(16,23,"KN-Srch Key Next");
  82.     PrintText(17,23,"LR-Last Record");
  83.     PrintText(18,23,"MF-Merge File");
  84.  
  85.     PrintText(13,41,"NT-Encrypt Table");
  86.     PrintText(14,41,"NR-Next Record");
  87.     PrintText(15,41,"OT-Open Table");
  88.     PrintText(16,41,"PT-Copy Table");
  89.     PrintText(17,41,"PR-Prev Record");
  90.     PrintText(18,41,"QU-Quit");
  91.  
  92.     PrintText(13,59,"RT-Rename Table");
  93.     PrintText(14,59,"SF-Srch Field 1st");
  94.     PrintText(15,59,"SN-Srch Field Next");
  95.     PrintText(16,59,"TT-Create Table");
  96.     PrintText(17,59,"YT-Empty Table");
  97.  
  98.     PrintText(18,58, "[Choice:      ]");
  99.  
  100.     PrintText(21,2,"File: None");
  101.     PrintText(21,20,"Records: 0");
  102.     PrintText(21,35,"Fields: 0");
  103.     PrintText(21,49,"Key Fields: 0");
  104.     PrintText(21,66,"Rec No: 0");
  105.     
  106. }
  107.  
  108. int ValidEvent(char *Choice) {
  109.  
  110.     int Index,Ret=1,Process=0;
  111.  
  112.     static PROCESS EventArray[] = {
  113.         {"AR","Record Add Successful",AddRecord},
  114.         {"CT","Table Close Successful",CloseFile},
  115.         {"DT","Table Decrypt Successful",DecryptFile},
  116.         {"DR","Record Delete Successful",DeleteRecord},
  117.         {"ET","Table Delete Successful",DeleteFile},
  118.         {"ER","Record Update Successful",EditRecord},
  119.         {"FR","First Record Successful",FirstRecord},
  120.         {"GR","Goto Record Successful",GotoRecord},
  121.         {"KF","Search Key 1st Successful",SearchKFirst},
  122.         {"KN","Search Key Next Successful",SearchKNext},
  123.         {"LR","Last Record Successful",LastRecord},
  124.         {"MT","Table Merge Successful",MergeFile},
  125.         {"NT","Table Encrypt Successful",EncryptFile},
  126.         {"NR","Next Record Successful",NextRecord},
  127.         {"OT","Table Open Successful",OpenFile},
  128.         {"PT","Table Copy Successful",CopyFile},
  129.         {"PR","Prev Record Successful",PreviousRecord},
  130.         {"RT","Table Rename Successful",RenameFile},
  131.         {"SF","Search Field 1st Successful",SearchFFirst},
  132.         {"SN","Search Field Next Successful",SearchFNext},
  133.         {"TT","Table Create Successful",CreateFile},
  134.         {"YT","Table Empty Successful",EmptyFile}
  135.     };
  136.  
  137.     if (strncmp(Choice,"QU",2) == 0)
  138.         return(0);
  139.  
  140.     for (Index = 0; Index < 23; Index++)
  141.         if (strncmp(Choice,EventArray[Index].Item,2) == 0) {
  142.             Process=1;
  143.             break;
  144.         }
  145.  
  146.     if (Process) {
  147.         Ret = (EventArray[Index].Execute)();
  148.         if (!Ret)
  149.             PrintText(24,6,EventArray[Index].Message);
  150.         else
  151.             VLIBError1(Ret);
  152.     }
  153.     else 
  154.         PrintFText(YES,24,6,"%s is an invalid option - Hit any Key",Choice);
  155.     return(1);
  156.  
  157. }
  158.  
  159.  
  160.  
  161. int AddRecord(void) {
  162.  
  163.     VLIBTABLEENTRY RecordEntry;
  164.  
  165.     if (EditRec(&RecordEntry,NO)) {
  166.         if ((VLIBRet = VLIBRecInsert(&RecordEntry)) == PXSUCCESS) {
  167.             DisplayRecord(&RecordEntry);
  168.             UpdateParadoxInfo(YES);
  169.         }
  170.     }
  171.     return(VLIBRet);
  172. }
  173. int CloseFile(void) {
  174.  
  175.     UpdateParadoxInfo(NO);
  176.     ClearRecord();
  177.     return(VLIBTblClose());
  178. }
  179.  
  180. int SearchFFirst(void) {
  181.  
  182.     VLIBTABLEENTRY RecordEntry;
  183.  
  184.     GotSrchFFirst = FALSE;
  185.     memset((VLIBTABLEENTRY *)&SearchRecord,'\0',sizeof(VLIBTABLEENTRY));
  186.     VLIBRet = -1;
  187.     if (SrchRec(&SearchRecord,NO)) {
  188.         ClearMessageArea();
  189.         if ((VLIBRet = VLIBRecGet(&RecordEntry)) == PXSUCCESS) {
  190.             DisplayRecord(&RecordEntry);
  191.             UpdateParadoxInfo(YES);
  192.             GotSrchFFirst = TRUE;
  193.         }
  194.     }
  195.  
  196.     return(VLIBRet);
  197. }
  198.  
  199. int SearchFNext(void) {
  200.  
  201.     VLIBTABLEENTRY RecordEntry;
  202.  
  203.     VLIBRet = -1;
  204.     if (GotSrchFFirst) {
  205.         if (SrchRec(&SearchRecord,NO)) {
  206.             ClearMessageArea();
  207.             if ((VLIBRet = VLIBRecGet(&RecordEntry)) == PXSUCCESS) {
  208.                 DisplayRecord(&RecordEntry);
  209.                 UpdateParadoxInfo(YES);
  210.                 GotSrchFFirst = TRUE;
  211.             }
  212.         }
  213.     }
  214.     else
  215.         PrintText(24,6,"No search field is set up, call Srch Field 1st");
  216.     return(VLIBRet);
  217. }
  218. int SearchKFirst(void) {
  219.  
  220.     VLIBTABLEENTRY RecordEntry;
  221.  
  222.     memset((VLIBTABLEENTRY *)&SearchRecord,'\0',sizeof(VLIBTABLEENTRY));
  223.     GotSrchKFirst = FALSE;
  224.     VLIBRet = -1;
  225.     if (SrchRec(&SearchRecord,YES)) {
  226.         ClearMessageArea();
  227.         if ((VLIBRet = VLIBSrchKey(SEARCHFIRST,NumKeys,&SearchRecord)) == PXSUCCESS)    {
  228.             if ((VLIBRet = VLIBRecGet(&RecordEntry)) == PXSUCCESS) {
  229.                 DisplayRecord(&RecordEntry);
  230.                 UpdateParadoxInfo(YES);
  231.                 GotSrchKFirst = TRUE;
  232.             }
  233.         }
  234.     }
  235.     return(VLIBRet);
  236. }
  237. int SearchKNext(void) {
  238.  
  239.     VLIBTABLEENTRY RecordEntry;
  240.  
  241.     VLIBRet = -1;
  242.     if (GotSrchKFirst) {
  243.         if ((VLIBRet = VLIBSrchKey(SEARCHNEXT,NumKeys,&SearchRecord)) == PXSUCCESS)    {
  244.             if (VLIBRecGet(&RecordEntry) == PXSUCCESS) {
  245.                 DisplayRecord(&RecordEntry);
  246.                 UpdateParadoxInfo(YES);
  247.             }
  248.         }
  249.     }
  250.     else
  251.         PrintText(24,6,"No search key is set up, call Srch Key 1st");
  252.  
  253.     return(VLIBRet);
  254. }
  255. int DecryptFile(void) {
  256.  
  257.     char Choice[16];
  258.     int IsProtected;
  259.  
  260.     if ((VLIBRet = VLIBTblProtected(&IsProtected)) == PXSUCCESS) {
  261.         if (IsProtected) {
  262.             PrintFText(NO,24,6,"Enter Password:");
  263.             GetString(24,23,15,Choice,NO);
  264.             ClearMessageArea();
  265.             return(VLIBTblDecrypt(Choice));
  266.         }
  267.         else {
  268.             VLIBRet = -1;
  269.             PrintText(24,6,"Table is not encrypted");
  270.         }
  271.     }
  272.     return(VLIBRet);
  273. }
  274.  
  275. int DeleteRecord(void) {
  276.  
  277.     char Choice[3]; 
  278.     VLIBTABLEENTRY RecordEntry;
  279.  
  280.      PrintFText(NO,24,6,"Delete Current Record (Y or N):");
  281.     GetString(24,38,1,Choice,YES);
  282.     ClearMessageArea();
  283.     VLIBRet = -1;
  284.     if (Choice[0] == 'Y')
  285.         if ((VLIBRet = VLIBRecDelete()) == PXSUCCESS) {
  286.             if ((VLIBRet = VLIBRecGet(&RecordEntry)) == PXSUCCESS) {
  287.                 DisplayRecord(&RecordEntry);
  288.                 UpdateParadoxInfo(YES);
  289.             }
  290.             else {
  291.                 if (VLIBRet == PXERR_TABLEEMPTY) {
  292.                     ClearRecord();
  293.                     UpdateParadoxInfo(YES);
  294.                 }
  295.             }
  296.         }
  297.     return(VLIBRet);
  298.  
  299. }
  300.  
  301. int DeleteFile(void) {
  302.     
  303.     UpdateParadoxInfo(NO);
  304.     ClearRecord();
  305.     return(VLIBTblDelete());
  306. }
  307.  
  308. int EditRecord(void) {
  309.  
  310.     VLIBTABLEENTRY RecordEntry;
  311.     VLIBRet = -1;
  312.     if (EditRec(&RecordEntry,YES)) {
  313.         if ((VLIBRet = VLIBRecUpdate(&RecordEntry)) == PXSUCCESS) {
  314.             DisplayRecord(&RecordEntry);
  315.         }
  316.     }
  317.     return(VLIBRet);
  318. }
  319.  
  320. int FirstRecord(void) {
  321.  
  322.     VLIBTABLEENTRY RecordEntry;
  323.  
  324.     if ((VLIBRet = VLIBRecFirst(&RecordEntry)) == PXSUCCESS) {
  325.         DisplayRecord(&RecordEntry);
  326.         UpdateParadoxInfo(YES);
  327.     }
  328.     return(VLIBRet);
  329. }
  330. int GotoRecord(void) {
  331.  
  332.     char Choice[8];
  333.     VLIBTABLEENTRY RecordEntry;
  334.     RECORDNUMBER Value;
  335.  
  336.     PrintFText(NO,24,6,"Goto record No:");
  337.     GetString(24,22,6,Choice,NO);
  338.     Value = atol(Choice);
  339.     ClearMessageArea();
  340.     if ((VLIBRet = VLIBRecGoto(Value)) == PXSUCCESS) {
  341.         if ((VLIBRet = VLIBRecGet(&RecordEntry)) == PXSUCCESS) {
  342.             DisplayRecord(&RecordEntry);
  343.             UpdateParadoxInfo(YES);
  344.         }
  345.     }
  346.     return(VLIBRet);
  347. }
  348. int LastRecord(void) {
  349.  
  350.     VLIBTABLEENTRY RecordEntry;
  351.  
  352.     if ((VLIBRet = VLIBRecLast(&RecordEntry)) == PXSUCCESS) {
  353.         DisplayRecord(&RecordEntry);
  354.         UpdateParadoxInfo(YES);
  355.     }
  356.     return(VLIBRet);
  357. }
  358. int MergeFile(void) {
  359.  
  360.     char Choice[9];
  361.  
  362.     PrintFText(NO,24,6,"File to merge into %s.db (No Extension):",VLIBName);
  363.     GetString(24,49,8,Choice,YES);
  364.     ClearMessageArea();
  365.     return(VLIBTblAdd(Choice,DESTINATION));
  366.  
  367. }
  368.  
  369. int EncryptFile(void) {
  370.  
  371.     char Choice[16];
  372.  
  373.     PrintFText(NO,24,6,"Enter Password:");
  374.     GetString(24,23,15,Choice,NO);
  375.     ClearMessageArea();
  376.     return(VLIBTblEncrypt(Choice));
  377. }
  378.  
  379. int NextRecord(void) {
  380.  
  381.     VLIBTABLEENTRY RecordEntry;
  382.  
  383.     if ((VLIBRet = VLIBRecNext(&RecordEntry)) == PXSUCCESS) {
  384.         DisplayRecord(&RecordEntry);
  385.         UpdateParadoxInfo(YES);
  386.     }
  387.     return(VLIBRet);
  388. }
  389. int OpenFile(void) {
  390.     char Choice[16];
  391.     char *Value = NULL;
  392.     int IsProtected;
  393.  
  394.     if ((VLIBRet = VLIBTblProtected(&IsProtected)) == PXSUCCESS) {
  395.         if (IsProtected) {
  396.             PrintFText(NO,24,6,"Enter Password:");
  397.             GetString(24,23,15,Choice,NO);
  398.             ClearMessageArea();
  399.             Value = Choice;
  400.         }
  401.     }
  402.     else
  403.         return(VLIBRet);
  404.     if ((VLIBRet = VLIBTblOpen(Value)) == PXSUCCESS)
  405.         return(FirstRecord());
  406.     return(VLIBRet);
  407. }
  408. int PreviousRecord(void) {
  409.  
  410.     VLIBTABLEENTRY RecordEntry;
  411.  
  412.     if ((VLIBRet = VLIBRecPrev(&RecordEntry)) == PXSUCCESS) {
  413.         DisplayRecord(&RecordEntry);
  414.         UpdateParadoxInfo(YES);
  415.     }
  416.     return(VLIBRet);
  417. }
  418.  
  419. int Quit(void) {
  420.     return(1);
  421. }
  422.  
  423. int RenameFile(void) {
  424.  
  425.     char Choice[9];
  426.     
  427.     PrintFText(NO,24,6,"Rename %s.DB to (No extension):",VLIBName);
  428.     GetString(24,40,8,Choice,YES);
  429.     ClearMessageArea();
  430.     return(VLIBTblRename(Choice));
  431. }
  432. int CreateFile(void) {
  433.  
  434.     char Choice[3];
  435.  
  436.     VLIBRet = -1;
  437.     PrintFText(NO,24,6,"Over Write %s.DB (Y or N):",VLIBName);
  438.     GetString(24,35,1,Choice,YES);
  439.     ClearMessageArea();
  440.     if (Choice[0] == 'Y')
  441.         return(VLIBTblCreate(64));
  442.     return(VLIBRet);
  443. }
  444. int EmptyFile(void) {
  445.  
  446.     ClearRecord();
  447.     return(VLIBTblEmpty());
  448. }
  449. int CopyFile(void) {
  450.  
  451.     char Choice[9];
  452.     
  453.     PrintFText(NO,24,6,"File to copy from (No extension):");
  454.     GetString(24,40,8,Choice,YES);
  455.     ClearMessageArea();
  456.     return(VLIBTblCopy(Choice,DESTINATION));
  457. }
  458.  
  459. void UpdateParadoxInfo(BOOLEAN UseInfo) {
  460.  
  461.     static int PRow = 21;
  462.     static int PCol[] = {8,29,43,61,74};
  463.     RECORDNUMBER NumRecs=0,CurrRec=0;
  464.     int NumFields=0;
  465.     int NKeys=0;
  466.     char TableName[13];
  467.  
  468.     strcpy(TableName,"None");
  469.     if (UseInfo) {
  470.         strcpy(TableName,VLIBName);
  471.         strcat(TableName,".DB");
  472.         VLIBTblNRecs(&NumRecs);
  473.         VLIBRecNFlds(&NumFields);
  474.         VLIBKeyNFlds(&NKeys);
  475.         VLIBRecNum(&CurrRec);
  476.     }
  477.  
  478.     PrintText(PRow,PCol[0],"            ");
  479.     PrintText(PRow,PCol[1],"    ");
  480.     PrintText(PRow,PCol[2],"    ");
  481.     PrintText(PRow,PCol[3],"    ");
  482.     PrintText(PRow,PCol[4],"    ");
  483.  
  484.     PrintFText(NO,PRow,PCol[0],"%s",TableName);
  485.     PrintFText(NO,PRow,PCol[1],"%ld",NumRecs);
  486.     PrintFText(NO,PRow,PCol[2],"%d",NumFields);
  487.     PrintFText(NO,PRow,PCol[3],"%d",NKeys);
  488.     PrintFText(NO,PRow,PCol[4],"%ld",CurrRec);
  489.  
  490. }
  491.  
  492. void DisplayRecord(VLIBTABLEENTRY *RecordEntry) {
  493.  
  494.     static DRow[] = {4,4,5,6,6,7,7,7,9,9,9,9,10,10,10};
  495.     static DCol[] = {15,74,15,15,60,15,45,68,15,32,53,70,14,33,53};
  496.  
  497.     ClearRecord();
  498.     PrintFText(NO,DRow[0],DCol[0],"%s",RecordEntry->Title);
  499.     PrintFText(NO,DRow[1],DCol[1],"%s",RecordEntry->Rating);
  500.     PrintFText(NO,DRow[2],DCol[2],"%s",RecordEntry->Stars);
  501.     PrintFText(NO,DRow[3],DCol[3],"%s",RecordEntry->Cast);
  502.     PrintFText(NO,DRow[4],DCol[4],"%s",RecordEntry->Director);
  503.     PrintFText(NO,DRow[5],DCol[5],"%s",RecordEntry->Company);
  504.     PrintFText(NO,DRow[6],DCol[6],"%s",RecordEntry->Category);
  505.     PrintFText(NO,DRow[7],DCol[7],"%02d/%02d/%d",RecordEntry->DateMonth,RecordEntry->DateDay,RecordEntry->DateYear);
  506.     PrintFText(NO,DRow[8],DCol[8],"%3.2f",RecordEntry->Price);
  507.     PrintFText(NO,DRow[9],DCol[9],"%d",RecordEntry->Tape);
  508.     PrintFText(NO,DRow[10],DCol[10],"%2.2f",RecordEntry->RunTime);
  509.     PrintFText(NO,DRow[11],DCol[11],"%s",RecordEntry->Format);
  510.     PrintFText(NO,DRow[12],DCol[12],"%d",RecordEntry->Start);
  511.     PrintFText(NO,DRow[13],DCol[13],"%d",RecordEntry->Stop);
  512.     PrintFText(NO,DRow[14],DCol[14],"%s",RecordEntry->RunSpeed);
  513.  
  514. }
  515.  
  516. void ClearRecord(void) {
  517.  
  518.     static CRow[] = {4,4,5,6,6,7,7,7,9,9,9,9,10,10,10};
  519.     static CCol[] = {15,74,15,15,60,15,45,68,15,32,53,70,14,33,53};
  520.     static Len[] = {40,5,55,30,15,15,10,10,7,5,7,8,7,7,10};
  521.     int Index;
  522.     char Spaces[80];
  523.     
  524.  
  525.     memset(Spaces,'\0',sizeof(Spaces));
  526.     memset(Spaces,' ',sizeof(Spaces)-1);
  527.  
  528.     for (Index =0; Index < 15; Index++)
  529.         PrintFText(NO,CRow[Index],CCol[Index],"%*.*s",Len[Index],Len[Index],Spaces);
  530. }
  531.  
  532. int EditRec(VLIBTABLEENTRY *RecordEntry,BOOLEAN EditOnly) {
  533.  
  534.     char Choice[80];
  535.  
  536.     static ERow[] = {4,4,5,6,6,7,7,7,9,9,9,9,10,10,10};
  537.     static ECol[] = {15,74,15,15,60,15,45,68,15,32,53,70,14,33,53};
  538.     static ELen[] = {40,5,55,30,15,15,10,10,7,5,7,8,7,7,10};
  539.  
  540.     memset(RecordEntry,'\0',sizeof(VLIBTABLEENTRY));
  541.  
  542.     if (EditOnly) {
  543.         if (VLIBRecGet(RecordEntry) != PXSUCCESS)
  544.             return(0); 
  545.     }
  546.     else
  547.       ClearRecord();
  548.  
  549.     GetString(ERow[0],ECol[0],ELen[0],RecordEntry->Title,NO);
  550.     GetString(ERow[1],ECol[1],ELen[1],RecordEntry->Rating,NO);
  551.     GetString(ERow[2],ECol[2],ELen[2],RecordEntry->Stars,NO);
  552.     GetString(ERow[3],ECol[3],ELen[3],RecordEntry->Cast,NO);
  553.     GetString(ERow[4],ECol[4],ELen[4],RecordEntry->Director,NO);
  554.     GetString(ERow[5],ECol[5],ELen[5],RecordEntry->Company,NO);
  555.     GetString(ERow[6],ECol[6],ELen[6],RecordEntry->Category,NO);
  556.     if (!EditOnly)
  557.         PrintText(ERow[7],ECol[7],"  /  /");
  558.  
  559.     if (EditOnly) {
  560.         sprintf(Choice,"%d",RecordEntry->DateMonth);
  561.         GetString(ERow[7],ECol[7],2,Choice,NO);
  562.         RecordEntry->DateMonth = atoi(Choice); 
  563.         sprintf(Choice,"%d",RecordEntry->DateDay);
  564.         GetString(ERow[7],ECol[7]+3,2,Choice,NO);
  565.         RecordEntry->DateDay = atoi(Choice);
  566.         sprintf(Choice,"%d",RecordEntry->DateYear);
  567.         GetString(ERow[7],ECol[7]+6,4,Choice,NO);
  568.         RecordEntry->DateYear = atoi(Choice);
  569.  
  570.         sprintf(Choice,"%3.2f",RecordEntry->Price);
  571.         GetString(ERow[8],ECol[8],ELen[8],Choice,NO);
  572.         RecordEntry->Price = atof(Choice);
  573.  
  574.         sprintf(Choice,"%d",RecordEntry->Tape);
  575.         GetString(ERow[9],ECol[9],ELen[9],Choice,NO);
  576.         RecordEntry->Tape = atoi(Choice);
  577.  
  578.         sprintf(Choice,"%3.2f",RecordEntry->RunTime);
  579.         GetString(ERow[10],ECol[10],ELen[10],Choice,NO);
  580.         RecordEntry->RunTime = atof(Choice);
  581.  
  582.     }
  583.     else {
  584.         GetString(ERow[7],ECol[7],2,Choice,NO);
  585.         RecordEntry->DateMonth = atoi(Choice); 
  586.         GetString(ERow[7],ECol[7]+3,2,Choice,NO);
  587.         RecordEntry->DateDay = atoi(Choice);
  588.         GetString(ERow[7],ECol[7]+6,2,Choice,NO);
  589.         RecordEntry->DateYear = atoi(Choice);
  590.         GetString(ERow[8],ECol[8],ELen[8],Choice,NO);
  591.         RecordEntry->Price = atof(Choice);
  592.         GetString(ERow[9],ECol[9],ELen[9],Choice,NO);
  593.         RecordEntry->Tape = atoi(Choice);
  594.         GetString(ERow[10],ECol[10],ELen[10],Choice,NO);
  595.         RecordEntry->RunTime = atof(Choice);
  596.  
  597.     }
  598.  
  599.     GetString(ERow[11],ECol[11],ELen[11],RecordEntry->Format,NO);
  600.  
  601.     if (EditOnly) {
  602.           sprintf(Choice,"%d",RecordEntry->Start);
  603.         GetString(ERow[12],ECol[12],ELen[12],Choice,NO);
  604.         RecordEntry->Start = atoi(Choice);
  605.         sprintf(Choice,"%d",RecordEntry->Stop);
  606.         GetString(ERow[13],ECol[13],ELen[13],Choice,NO);
  607.         RecordEntry->Stop = atoi(Choice);
  608.     }
  609.     else {
  610.         GetString(ERow[12],ECol[12],ELen[12],Choice,NO);
  611.         RecordEntry->Start = atoi(Choice);
  612.         GetString(ERow[13],ECol[13],ELen[13],Choice,NO);
  613.         RecordEntry->Stop = atoi(Choice);
  614.     }
  615.  
  616.     GetString(ERow[14],ECol[14],ELen[14],RecordEntry->RunSpeed,NO);
  617.     return(1);
  618.     
  619. }
  620.  
  621.  
  622. int SrchRec(VLIBTABLEENTRY *RecordEntry,BOOLEAN KeyOrFld) {
  623.  
  624.     static SRow[] = {4,4,5,6,6,7,7,7,9,9,9,9,10,10,10};
  625.     static SCol[] = {15,74,15,15,60,15,45,68,15,32,53,70,14,33,53};
  626.     static SLen[] = {40,5,55,30,15,15,10,10,7,5,7,8,7,7,10};
  627.     static char *FieldArray[] = {
  628.                                         "Title",
  629.                                         "Rating",
  630.                                         "Stars",
  631.                                         "Cast",
  632.                                         "Director",
  633.                                         "Company",
  634.                                         "Category",
  635.                                         "Date",
  636.                                         "Price",
  637.                                         "Tape",
  638.                                         "RunTime",
  639.                                         "Format",
  640.                                         "Start",
  641.                                         "Stop",
  642.                                         "RunSpeed"
  643.                                            };
  644.     int Field,NumFields,NKeys;
  645.     int Mode=SEARCHFIRST,Ret=1;
  646.  
  647.     char Choice[80];
  648.     
  649.     ClearRecord();
  650.  
  651.     if (VLIBRecNFlds(&NumFields) != PXSUCCESS)
  652.         return(0);
  653.     if (VLIBKeyNFlds(&NKeys) != PXSUCCESS)
  654.         return(0);
  655.     if (KeyOrFld) {    /* only key fields */
  656.     
  657.         PrintFText(NO,24,6,"Number of keys to search on (1 or %d):",NKeys);
  658.         GetString(24,44,1,Choice,YES);
  659.         ClearMessageArea();
  660.         Field = atoi(Choice);
  661.         if (Field < 1 || Field > NKeys) {
  662.             PrintFText(YES,24,6,"Invalid number of keys - Hit any Key");
  663.             return(0);
  664.         }
  665.         NumKeys=Field;
  666.         switch (Field) {
  667.             case 2:
  668.                 GetString(SRow[0],SCol[0],SLen[0],RecordEntry->Title,NO);
  669.             case 1:
  670.                 GetString(SRow[6],SCol[6],SLen[6],RecordEntry->Category,NO);
  671.             break;
  672.         }
  673.     }
  674.     else {
  675.         if (!GotSrchFFirst) {
  676.             PrintFText(NO,24,6,"Field to search on (1 - %d):",NumFields);
  677.             GetString(24,34,2,Choice,YES);
  678.             ClearMessageArea();
  679.             Field = atoi(Choice);
  680.             if (Field < 1 || Field > NumFields) {
  681.                 PrintFText(YES,24,6,"%d Invalid Field Number  - Hit any Key",Field);
  682.                 return(0);
  683.             }
  684.             FieldNum=Field;
  685.         }
  686.         else {
  687.             Mode = SEARCHNEXT;
  688.             Field = FieldNum;
  689.         }
  690.         switch(Field) {
  691.             case 1:
  692.                 if (!GotSrchFFirst)
  693.                     GetString(SRow[0],SCol[0],SLen[0],RecordEntry->Title,NO);
  694.             break;
  695.             case 2:
  696.                 if (!GotSrchFFirst)
  697.                     GetString(SRow[1],SCol[1],SLen[1],RecordEntry->Rating,NO);
  698.             break;
  699.             case 3:
  700.                 if (!GotSrchFFirst)
  701.                     GetString(SRow[2],SCol[2],SLen[2],RecordEntry->Stars,NO);
  702.             break;
  703.             case 4:
  704.                 if (!GotSrchFFirst)
  705.                     GetString(SRow[3],SCol[3],SLen[3],RecordEntry->Cast,NO);
  706.             break;
  707.             case 5:
  708.                 if (!GotSrchFFirst)
  709.                     GetString(SRow[4],SCol[4],SLen[4],RecordEntry->Director,NO);
  710.             break;
  711.             case 6:
  712.                 if (!GotSrchFFirst)
  713.                     GetString(SRow[5],SCol[5],SLen[5],RecordEntry->Company,NO);
  714.             break;
  715.             case 7:
  716.                 if (!GotSrchFFirst)
  717.                     GetString(SRow[6],SCol[6],SLen[6],RecordEntry->Category,NO);
  718.             break;
  719.             case 8:
  720.                 if (!GotSrchFFirst) {
  721.                     GetString(SRow[7],SCol[7],2,Choice,NO);
  722.                     RecordEntry->DateMonth = atoi(Choice); 
  723.                     GetString(SRow[7],SCol[7]+3,2,Choice,NO);
  724.                     RecordEntry->DateDay = atoi(Choice);
  725.                     GetString(SRow[7],SCol[7]+6,2,Choice,NO);
  726.                     RecordEntry->DateYear = atoi(Choice);
  727.                 }
  728.             break;
  729.             case 9:
  730.                 if (!GotSrchFFirst) {
  731.                     GetString(SRow[8],SCol[8],SLen[8],Choice,NO);
  732.                     RecordEntry->Price = atof(Choice);
  733.                 }
  734.             break;
  735.             case 10:
  736.                 if (!GotSrchFFirst) {
  737.                     GetString(SRow[9],SCol[9],SLen[9],Choice,NO);
  738.                     RecordEntry->Tape = atoi(Choice);
  739.                 }
  740.             break;
  741.             case 11:
  742.                 if (!GotSrchFFirst) {
  743.                     GetString(SRow[10],SCol[10],SLen[10],Choice,NO);
  744.                     RecordEntry->RunTime = atof(Choice);
  745.                 }
  746.             break;
  747.             case 12:
  748.                 if (!GotSrchFFirst)
  749.                     GetString(SRow[11],SCol[11],SLen[11],RecordEntry->Format,NO);
  750.             break;
  751.             case 13:
  752.                 if (!GotSrchFFirst) {
  753.                     GetString(SRow[12],SCol[12],SLen[12],Choice,NO);
  754.                     RecordEntry->Start = atoi(Choice);
  755.                 }
  756.             break;
  757.             case 14:
  758.                 if (!GotSrchFFirst) {
  759.                     GetString(SRow[13],SCol[13],SLen[13],Choice,NO);
  760.                     RecordEntry->Stop = atoi(Choice);
  761.                 }
  762.             break;
  763.             case 15:
  764.                 if (!GotSrchFFirst)
  765.                     GetString(SRow[14],SCol[14],SLen[14],RecordEntry->RunSpeed,NO);
  766.             break;
  767.             
  768.         }
  769.         if (VLIBSrchFld(Mode,FieldArray[Field-1],RecordEntry) != PXSUCCESS)
  770.             Ret=0;
  771.     }
  772.     return(Ret);    
  773.     
  774. }
  775.  
  776. int VLIBError1(int ErrCode) {
  777.  
  778.     if (ErrCode > 0) {
  779.         PrintFText(YES,24,6,"[Err :%d] %s (Hit any Key)",ErrCode,PXErrMsg(ErrCode));
  780.         return(ErrCode);
  781.     }
  782.     return(PXSUCCESS);
  783. }
  784.  
  785.